<template>
  <div class="gzyctb-container">
    <!-- Tab切换 -->
    <el-tabs v-model="activeTab" class="data-tabs">
      <!-- 填报中Tab -->
      <el-tab-pane label="填报中" name="pending">
        <!-- 工具栏 -->
        <div class="toolbar">
          <div class="search-section">
            <el-date-picker 
              v-model="selectedWeek" 
              type="week" 
              format="yyyy 第 WW 周" 
              value-format="yyyy-MM-dd"
              placeholder="按周选择时间组件" 
              class="date-picker-custom week-picker-enhanced" 
              :editable="false" 
              :clearable="true"
              :picker-options="weekPickerOptions" 
              @change="handleWeekChange">
            </el-date-picker>
            <el-button type="primary" @click="searchData">查询</el-button>
            <!-- 文件下载按钮 -->
            <el-button type="info" @click="downloadFile">操作手册</el-button>
          </div>
        </div>

        <!-- 操作按钮行 -->
        <div class="action-bar">
          <el-button type="warning" @click="openAddDialog">新增</el-button>
          <el-button type="success" @click="editSelected">编辑</el-button>
          <el-button type="info" @click="submitSelected">上报</el-button>
          <el-button type="danger" @click="deleteSelected">删除</el-button>

        </div>

        <div class="table-container">
          <el-table 
            ref="pendingTable" 
            :data="filteredPendingData" 
            border 
            stripe 
            style="width: 100%" 
            height="calc(100vh - 300px)"
            @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="55"></el-table-column>
            <el-table-column prop="unit" label="单位" width="120" fixed="left"></el-table-column>
            <el-table-column prop="userName" label="填报人" width="120" fixed="left"></el-table-column>
            <el-table-column prop="phone" label="联系电话" width="120" fixed="left"></el-table-column>
            
            <!-- 配变（单位：台）列组 -->
            <el-table-column label="配变（单位：台）" align="center">
              <el-table-column prop="totalTransformer" label="总数" width="100" align="center"></el-table-column>
              <el-table-column prop="publicTransformer" label="公变" width="100" align="center"></el-table-column>
              <el-table-column prop="privateTransformer" label="专变" width="100" align="center"></el-table-column>
            </el-table-column>
            
            <!-- 负载（单位：台）列组 -->
            <el-table-column label="负载（单位：台）" align="center">
              <el-table-column prop="overloadLoad" label="过载" width="100" align="center"></el-table-column>
              <el-table-column prop="heavyLoad" label="重载" width="100" align="center"></el-table-column>
            </el-table-column>
            
            <!-- 电压（单位：台）列组 -->
            <el-table-column label="电压（单位：台）" align="center">
              <el-table-column prop="severeLowVoltage" label="严重低电压" width="140" align="center"></el-table-column>
              <el-table-column prop="generalLowVoltage" label="一般低电压" min-width="140" align="center"></el-table-column>
            </el-table-column>
          </el-table>
        </div>

        <!-- 分页组件 -->
        <div class="pagination-container">
          <el-pagination 
            @size-change="handlePendingSizeChange" 
            @current-change="handlePendingCurrentChange"
            :current-page="pendingCurrentPage" 
            :page-sizes="[10, 20, 50, 100]" 
            :page-size="pendingPageSize"
            layout="total, sizes, prev, pager, next, jumper" 
            :total="pendingTotal">
          </el-pagination>
        </div>
      </el-tab-pane>

      <!-- 已上报Tab -->
      <el-tab-pane label="已填报" name="submitted">
        <div class="toolbar">
          <div class="search-section">
            <el-date-picker 
              v-model="selectedWeek" 
              type="week" 
              format="yyyy 第 WW 周" 
              value-format="yyyy-MM-dd"
              placeholder="按周选择时间组件" 
              class="date-picker-custom week-picker-enhanced" 
              :editable="false" 
              :clearable="true"
              :picker-options="weekPickerOptions" 
              @change="handleWeekChange">
            </el-date-picker>
            <el-button type="primary" @click="searchData">查询</el-button>
            <!-- 文件下载按钮 -->
            <el-button type="info" @click="downloadFile">操作手册</el-button>
          </div>
        </div>

        <div class="action-bar">
          <el-button type="success" @click="editSelected">编辑</el-button>
        </div>
        
        <div class="table-container">
          <el-table 
            ref="submittedTable" 
            :data="filteredSubmittedData" 
            border 
            stripe 
            style="width: 100%" 
            height="calc(100vh - 300px)"
            @selection-change="handleSubmittedSelectionChange">
            <el-table-column type="selection" width="55"></el-table-column>
            <el-table-column prop="unit" label="单位" width="120" fixed="left"></el-table-column>
            <el-table-column prop="userName" label="填报人" width="120" fixed="left"></el-table-column>
            <el-table-column prop="phone" label="联系电话" width="120" fixed="left"></el-table-column>
            
            <el-table-column label="配变（单位：台）" align="center">
              <el-table-column prop="totalTransformer" label="总数" width="100" align="center"></el-table-column>
              <el-table-column prop="publicTransformer" label="公变" width="100" align="center"></el-table-column>
              <el-table-column prop="privateTransformer" label="专变" width="100" align="center"></el-table-column>
            </el-table-column>
            
            <el-table-column label="负载（单位：台）" align="center">
              <el-table-column prop="overloadLoad" label="过载" width="100" align="center"></el-table-column>
              <el-table-column prop="heavyLoad" label="重载" width="100" align="center"></el-table-column>
            </el-table-column>
            
            <el-table-column label="电压（单位：台）" align="center">
              <el-table-column prop="severeLowVoltage" label="严重低电压" width="140" align="center"></el-table-column>
              <el-table-column prop="generalLowVoltage" label="一般低电压" min-width="140" align="center"></el-table-column>
            </el-table-column>
          </el-table>
        </div>

        <div class="pagination-container">
          <el-pagination 
            @size-change="handleSubmittedSizeChange" 
            @current-change="handleSubmittedCurrentChange"
            :current-page="submittedCurrentPage" 
            :page-sizes="[10, 20, 50, 100]" 
            :page-size="submittedPageSize"
            layout="total, sizes, prev, pager, next, jumper" 
            :total="submittedTotal">
          </el-pagination>
        </div>
      </el-tab-pane>
    </el-tabs>

    <!-- 新增/编辑对话框 -->
    <el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="800px" @close="resetForm">
      <el-form ref="dataForm" :model="formData" :rules="formRules" label-width="140px">
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="填报周" prop="reportWeek">
              <el-date-picker 
                v-model="formData.reportWeek" 
                type="week" 
                format="yyyy 第 WW 周" 
                value-format="yyyy-MM-dd"
                placeholder="请选择填报周" 
                class="date-picker-custom week-picker-enhanced" 
                :editable="false" 
                :clearable="true"
                :picker-options="weekPickerOptions" 
                style="width: 100%">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="联系电话" prop="phone">
              <el-input v-model="formData.phone" placeholder="请输入联系电话"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="单位" prop="unit">
              <el-input v-model="formData.unit" placeholder="请输入单位"></el-input>
            </el-form-item>
          </el-col>
        
          <el-col :span="12">
            <el-form-item label="总数" prop="totalTransformer">
              <el-input-number v-model="formData.totalTransformer" :min="0" placeholder="请输入总数" style="width: 100%"></el-input-number>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="公变" prop="publicTransformer">
              <el-input-number v-model="formData.publicTransformer" :min="0" placeholder="请输入公变数量" style="width: 100%"></el-input-number>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="专变" prop="privateTransformer">
              <el-input-number v-model="formData.privateTransformer" :min="0" placeholder="请输入专变数量" style="width: 100%"></el-input-number>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="负载过载" prop="overloadLoad">
              <el-input-number v-model="formData.overloadLoad" :min="0" placeholder="请输入负载过载数量" style="width: 100%"></el-input-number>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="重载" prop="heavyLoad">
              <el-input-number v-model="formData.heavyLoad" :min="0" placeholder="请输入重载数量" style="width: 100%"></el-input-number>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="严重低电压" prop="severeLowVoltage">
              <el-input-number v-model="formData.severeLowVoltage" :min="0" placeholder="请输入严重低电压数量" style="width: 100%"></el-input-number>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="一般低电压" prop="generalLowVoltage">
              <el-input-number v-model="formData.generalLowVoltage" :min="0" placeholder="请输入一般低电压数量" style="width: 100%"></el-input-number>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取消</el-button>
        <el-button type="primary" @click="saveData">确定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'GzyctbIndex',
  data() {
    return {
      activeTab: 'pending',
      dialogVisible: false,
      isEdit: false,
      selectedRows: [],
      selectedSubmittedRows: [],
      selectedWeek: '',
      weekPickerOptions: {
        firstDayOfWeek: 1,
        disabledDate(time) {
          return false
        },
        shortcuts: [
          {
            text: '本周',
            onClick(picker) {
              const now = new Date()
              const day = now.getDay()
              const diff = now.getDate() - day + (day === 0 ? -6 : 1)
              const monday = new Date(now.setDate(diff))
              picker.$emit('pick', monday)
            }
          },
          {
            text: '上周',
            onClick(picker) {
              const now = new Date()
              const day = now.getDay()
              const diff = now.getDate() - day + (day === 0 ? -6 : 1) - 7
              const lastMonday = new Date(now.setDate(diff))
              picker.$emit('pick', lastMonday)
            }
          }
        ]
      },
      pendingPageSize: 10,
      pendingCurrentPage: 1,
      submittedPageSize: 10,
      submittedCurrentPage: 1,
      formData: {
        reportWeek: '',
        unit: '',
        phone: '',
        totalTransformer: 0,
        publicTransformer: 0,
        privateTransformer: 0,
        overloadLoad: 0,
        heavyLoad: 0,
        severeLowVoltage: 0,
        generalLowVoltage: 0
      },
      formRules: {
        reportWeek: [
          { required: true, message: '请输入填报周', trigger: 'blur' }
        ],
        unit: [
          { required: true, message: '请输入单位', trigger: 'blur' }
        ],
        phone: [
          { required: true, message: '请输入联系电话', trigger: 'blur' }
        ]
      },
      pendingData: [],
      submittedData: [],
      pendingTotal: 0,
      submittedTotal: 0
    }
  },
  computed: {
    dialogTitle() {
      return this.isEdit ? '编辑信息' : '新增信息'
    },
    filteredPendingData() {
      return this.pendingData
    },
    filteredSubmittedData() {
      return this.submittedData
    }
  },
  mounted() {
    this.loadData()
  },
  watch: {
    activeTab(newVal) {
      this.loadData()
    }
  },
  methods: {
    searchData() {
      this.pendingCurrentPage = 1
      this.submittedCurrentPage = 1
      this.selectedRows = []
      this.selectedSubmittedRows = []
      this.loadData()
    },
    loadData() {
      // 构建查询参数
      const params = {
        pageNum: this.activeTab === 'pending' ? this.pendingCurrentPage : this.submittedCurrentPage,
        pageSize: this.activeTab === 'pending' ? this.pendingPageSize : this.submittedPageSize,
        status: this.activeTab === 'pending' ? '0' : '1'  // 0: 填报中, 1: 已上报
      }

      // 如果有选择周期，添加到查询参数
      if (this.selectedWeek) {
        params.reportWeek = this.convertDateToWeekFormat(this.selectedWeek)
      }

      let proxy = {
        url: '/pbcgzGzyctb/list',
        data: params
      }

      this.$oPost({ proxy }, (d) => {
        if (d.code === 1000) {
          // 确保 data 存在且格式正确
          if (d.data && d.data.list && Array.isArray(d.data.list)) {
            if (this.activeTab === 'pending') {
              this.pendingData = d.data.list
              this.pendingTotal = d.data.total || 0
            } else {
              this.submittedData = d.data.list
              this.submittedTotal = d.data.total || 0
            }
          } else {
            console.error('API 返回数据格式不正确:', d)
            this.$message.error('数据格式异常')
            this.resetDataArrays()
          }
        } else {
          console.error('API 请求失败:', d)
          this.$message.error(d.message || '查询失败')
          this.resetDataArrays()
        }
      }, (error) => {
        console.error('API 请求出错:', error)
        this.$message.error('网络请求失败')
        this.resetDataArrays()
      })
    },

    // 重置数据数组
    resetDataArrays() {
      if (this.activeTab === 'pending') {
        this.pendingData = []
        this.pendingTotal = 0
      } else {
        this.submittedData = []
        this.submittedTotal = 0
      }
    },
    handleWeekChange(value) {
      this.pendingCurrentPage = 1
      this.submittedCurrentPage = 1
      this.selectedRows = []
      this.selectedSubmittedRows = []
      this.loadData()
      if (value) {
        this.$message.success(`已选择周期：${this.formatWeekDisplay(value)}`)
      }
    },
    handlePendingSizeChange(val) {
      this.pendingPageSize = val
      this.pendingCurrentPage = 1
      this.selectedRows = []
      this.loadData()
    },
    handlePendingCurrentChange(val) {
      this.pendingCurrentPage = val
      this.selectedRows = []
      this.loadData()
    },
    handleSubmittedSizeChange(val) {
      this.submittedPageSize = val
      this.submittedCurrentPage = 1
      this.selectedSubmittedRows = []
      this.loadData()
    },
    handleSubmittedCurrentChange(val) {
      this.submittedCurrentPage = val
      this.selectedSubmittedRows = []
      this.loadData()
    },
    handleSelectionChange(selection) {
      this.selectedRows = selection
    },
    handleSubmittedSelectionChange(selection) {
      this.selectedSubmittedRows = selection
    },
    editSelected() {
      const selected = this.activeTab === 'pending' ? this.selectedRows : this.selectedSubmittedRows
      if (selected.length === 0) {
        this.$message.warning('请选择你要编辑的行数！')
        return
      }
      if (selected.length > 1) {
        this.$message.warning('请只选择一条记录进行编辑！')
        return
      }
      this.editRow(selected[0])
    },
    deleteSelected() {
      if (this.activeTab !== 'pending') {
        this.$message.warning('只有待上报的记录才能进行删除！')
        return
      }
      if (this.selectedRows.length === 0) {
        this.$message.warning('请选择你要删除的行数！')
        return
      }
      this.$confirm(`确认删除选中的 ${this.selectedRows.length} 条记录？`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        // 提取选中记录的ID数组
        const ids = this.selectedRows.map(row => row.id)

        let proxy = {
          url: 'pbcgzGzyctb/batchDelete',
          data: ids  // 直接传入ids数组
        }

        this.$oPost({ proxy }, (d) => {
          if (d.code === 1000) {
            this.$message.success('删除成功！')
            this.selectedRows = []
            // 重新加载数据
            this.loadData()
          } else {
            console.error('API 请求失败:', d)
            this.$message.error(d.message || '删除失败')
          }
        }, (error) => {
          console.error('API 请求出错:', error)
          this.$message.error('网络请求失败')
        })
      }).catch(() => {
        this.$message.info('已取消删除')
      })
    },
    submitSelected() {
      if (this.activeTab !== 'pending') {
        this.$message.warning('只有待上报的记录才能进行上报！')
        return
      }
      if (this.selectedRows.length === 0) {
        this.$message.warning('请选择你要上报的行数！')
        return
      }
      this.$confirm(`确认上报选中的 ${this.selectedRows.length} 条记录？`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        // 提取选中记录的ID数组
        const ids = this.selectedRows.map(row => row.id)

        let proxy = {
          url: 'pbcgzGzyctb/batchUpdateStatus',
          data: ids  // 直接传入ids数组
        }

        this.$oPost({ proxy }, (d) => {
          if (d.code === 1000) {
            this.$message.success('上报成功！')
            this.selectedRows = []
            // 重新加载数据
            this.loadData()
          } else {
            console.error('API 请求失败:', d)
            this.$message.error(d.message || '上报失败')
          }
        }, (error) => {
          console.error('API 请求出错:', error)
          this.$message.error('网络请求失败')
        })
      }).catch(() => {
        this.$message.info('已取消上报')
      })
    },
    openAddDialog() {
      this.isEdit = false
      this.dialogVisible = true
      this.resetForm()
    },
    editRow(row) {
      this.isEdit = true
      this.formData = { ...row }
      // 如果数据库中的reportWeek是数字格式（如202536），需要转换为日期格式
      if (this.formData.reportWeek && this.formData.reportWeek.length === 6) {
        this.formData.reportWeek = this.convertWeekFormatToDate(this.formData.reportWeek)
      }
      this.dialogVisible = true
    },
    saveData() {
      this.$refs.dataForm.validate((valid) => {
        if (valid) {
          if (this.isEdit) {
            this.updateData()
          } else {
            this.addData()
          }
        } else {
          this.$message.error('请完善必填信息！')
          return false
        }
      })
    },
    addData() {
      const requestData = {
        ...this.formData
      }

      // 将填报周转换为数字格式（如：202536）
      if (requestData.reportWeek) {
        requestData.reportWeek = this.convertDateToWeekFormat(requestData.reportWeek)
      }

      let proxy = {
        url: 'pbcgzGzyctb/add',
        data: requestData
      }

      this.$oPost({ proxy }, (d) => {
        if (d.code === 1000) {
          this.$message.success('新增成功！')
          this.dialogVisible = false
          this.resetForm()
          // 重新加载数据
          this.loadData()
        } else {
          console.error('新增失败:', d)
          this.$message.error(d.message || '新增失败')
        }
      }, (error) => {
        console.error('新增请求出错:', error)
        this.$message.error('网络请求失败')
      })
    },
    updateData() {
      const requestData = {
        ...this.formData
      }

      // 将填报周转换为数字格式（如：202536）
      if (requestData.reportWeek) {
        requestData.reportWeek = this.convertDateToWeekFormat(requestData.reportWeek)
      }

      let proxy = {
        url: 'pbcgzGzyctb/update',
        data: requestData
      }

      this.$oPost({ proxy }, (d) => {
        if (d.code === 1000) {
          this.$message.success('修改成功！')
          this.dialogVisible = false
          this.resetForm()
          // 重新加载数据
          this.loadData()
        } else {
          console.error('更新失败:', d)
          this.$message.error(d.message || '修改失败')
        }
      }, (error) => {
        console.error('更新请求出错:', error)
        this.$message.error('网络请求失败')
      })
    },
    resetForm() {
      this.formData = {
        reportWeek: '',
        unit: '',
        phone: '',
        totalTransformer: 0,
        publicTransformer: 0,
        privateTransformer: 0,
        overloadLoad: 0,
        heavyLoad: 0,
        severeLowVoltage: 0,
        generalLowVoltage: 0
      }
      if (this.$refs.dataForm) {
        this.$refs.dataForm.resetFields()
      }
    },
    formatWeekDisplay(dateStr) {
      if (!dateStr) return ''
      const date = new Date(dateStr)
      const year = date.getFullYear()
      const weekOfYear = this.getWeekOfYear(date)
      return `${year}年第${weekOfYear}周`
    },
    getWeekOfYear(date) {
      const firstDay = new Date(date.getFullYear(), 0, 1)
      const pastDaysOfYear = (date - firstDay) / 86400000
      return Math.ceil((pastDaysOfYear + firstDay.getDay() + 1) / 7)
    },

    // 日期转换方法
    convertDateToWeekFormat(dateStr) {
      if (!dateStr) return ''
      const date = new Date(dateStr)
      const year = date.getFullYear()
      const weekOfYear = this.getWeekOfYear(date)
      return year + String(weekOfYear).padStart(2, '0')
    },

    convertWeekFormatToDate(weekStr) {
      if (!weekStr || weekStr.length !== 6) return ''
      const year = parseInt(weekStr.substring(0, 4))
      const week = parseInt(weekStr.substring(4, 6))
      const jan4 = new Date(year, 0, 4)
      const jan4Day = jan4.getDay()
      const firstMonday = new Date(jan4)
      const daysToMonday = jan4Day === 0 ? -6 : 1 - jan4Day
      firstMonday.setDate(4 + daysToMonday)
      const targetMonday = new Date(firstMonday)
      targetMonday.setDate(firstMonday.getDate() + (week - 1) * 7)
      const targetYear = targetMonday.getFullYear()
      const targetMonth = String(targetMonday.getMonth() + 1).padStart(2, '0')
      const targetDay = String(targetMonday.getDate()).padStart(2, '0')
      return `${targetYear}-${targetMonth}-${targetDay}`
    },

    // 文件下载功能
    downloadFile() {
      // 您可以在这里设置实际的文件路径
      const fileUrl = '/path/to/your/manual.pdf'; // 请替换为实际的文件路径
      const fileName = '操作手册.pdf'; // 下载后的文件名
      
      // 创建一个隐藏的a标签来触发下载
      const link = document.createElement('a');
      link.href = fileUrl;
      link.download = fileName;
      link.style.display = 'none';
      document.body.appendChild(link);
      link.click();
      document.body.removeChild(link);
    }
  }
}
</script>

<style scoped>
.gzyctb-container {
  background: #f5f5f5;
  min-height: 100vh;
  padding: 0;
}

/* 工具栏样式 */
.toolbar {
  background: #fff;
  padding: 16px 24px;
  border-bottom: 1px solid #e4e7ed;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.search-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* 日期选择器样式 */
.date-picker-custom {
  width: 250px;
}

.week-picker-enhanced .el-input__inner {
  border-radius: 4px;
  font-size: 14px;
  border: 1px solid #dcdfe6;
}

.week-picker-enhanced .el-input__inner:focus {
  border-color: #409EFF;
  outline: none;
}

.week-picker-enhanced .el-input__inner:hover {
  border-color: #c0c4cc;
}

/* 操作按钮行样式 */
.action-bar {
  background: #fff;
  padding: 12px 24px;
  border-bottom: 1px solid #e4e7ed;
  display: flex;
  gap: 12px;
  align-items: center;
}

.action-bar .el-button {
  border-radius: 4px;
  font-size: 14px;
  padding: 8px 20px;
  min-width: 80px;
}

/* 按钮颜色定制 */
.action-bar .el-button--warning {
  background-color: #ff9500;
  border-color: #ff9500;
}

.action-bar .el-button--success {
  background-color: #67c23a;
  border-color: #67c23a;
}

.action-bar .el-button--danger {
  background-color: #f56c6c;
  border-color: #f56c6c;
}

.action-bar .el-button--info {
  background-color: #909399;
  border-color: #909399;
}

/* 表格容器样式 */
.table-container {
  background: #fff;
  padding: 0;
  margin: 0;
  height: calc(100vh - 300px);
  overflow: auto;
}

/* 分页组件样式 */
.pagination-container {
  background: #fff;
  padding: 16px 24px;
  border-top: 1px solid #e4e7ed;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

/* Tab样式定制 */
.data-tabs {
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.data-tabs .el-tabs__header {
  margin: 0;
  background: #fff;
  border-bottom: 1px solid #e4e7ed;
}

.data-tabs .el-tabs__nav {
  border: none;
}

.data-tabs .el-tabs__item {
  height: 50px;
  line-height: 50px;
  font-size: 14px;
  font-weight: 500;
  color: #606266;
  border-bottom: 2px solid transparent;
  transition: all 0.3s;
}

.data-tabs .el-tabs__item.is-active {
  color: #409EFF;
  border-bottom-color: #409EFF;
}

.data-tabs .el-tabs__item:hover {
  color: #409EFF;
}

/* 对话框样式 */
.dialog-footer {
  text-align: right;
}

.dialog-footer .el-button {
  margin-left: 10px;
}

/* 表格样式优化 */
.el-table {
  font-size: 13px;
}

.el-table th {
  background-color: #f8f9fa;
  color: #606266;
  font-weight: 600;
  border-bottom: 1px solid #e4e7ed;
}

.el-table td {
  border-bottom: 1px solid #f0f0f0;
}

.el-table--striped .el-table__body tr.el-table__row--striped td {
  background-color: #fafafa;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .toolbar {
    padding: 12px 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  
  .search-section {
    flex-direction: column;
    align-items: stretch;
  }
  
  .date-picker-custom {
    width: 100%;
  }
  
  .action-bar {
    padding: 12px 16px;
    flex-wrap: wrap;
  }
  
  .action-bar .el-button {
    flex: 1;
    margin: 2px;
    min-width: auto;
  }
  
  .pagination-container {
    padding: 12px 16px;
  }
}
</style>
